package sourismobile.MIDlet.core;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

public class ModuleList extends List implements CommandListener {

	static final String [] MODULE_NAMES = {"Presenter", "Mousse", "Audio"};
	static final int [] MODULE_CODE = {1, 2, 3};

	SourisMobileControler midlet;

	public ModuleList(SourisMobileControler midlet) {
		super("Modulet Selection", Choice.IMPLICIT);
		this.midlet = midlet;
		append ("Presenter", null);
		append ("Mousse", null);
		append ("Audio", null);
		setCommandListener(this);
	}

	public void commandAction(Command c, Displayable d) {
		if (c == List.SELECT_COMMAND) {
			midlet.setModule(MODULE_CODE[getSelectedIndex()], MODULE_NAMES[getSelectedIndex()]);
			midlet.back ();
		}
	}
}
